
//从键盘输入3个数（其中一个数用来代表加减乘除的符号，其余两个数用来计算），用来进行加/减/乘/除/取余

import java.util.Scanner;

public class Dmoe5 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int a = 0;
		int b = 0;
		boolean flag = false;
		String op;
		System.out.println("输入第一个数：");
		if (input.hasNextInt()) {
			a = input.nextInt();
		} else {
			System.err.println("数字输入有误");
			return;
		}

		System.out.println("输入运算符：");
		op = input.next();
		flag = op.equals("+") || op.equals("-") || op.equals("*") || op.equals("/") || op.equals("%");
		if (!flag) {
			System.err.println("运算符错误");
			return;
		}

		System.out.println("输入第二个数：");
		if (input.hasNextInt()) {
			b = input.nextInt();
		} else {
			System.err.println("数字输入有误");
		}
		switch (op) {
		case "+":
			System.out.println(a + "+" + b + "=" + (a + b));
			break;
		case "-":
			System.out.println(a + "-" + b + "=" + (a - b));
			break;
		case "*":
			System.out.println(a + "*" + b + "=" + (a * b));
			break;
		case "/":
			if (b != 0) {
				System.out.println(a + "/" + b + "=" + (a / b));
			} else {
				System.out.println("除数不能为零");
			}
			break;
		case "%":
			System.out.println(a + "%" + b + "=" + (a % b));
			break;
		default:
			break;
		}
	}
}
